<!DOCTYPE html>
<html>

	<head>

		<meta name="viewport" content="width=device-width-10, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
		<meta charset="UTF-8">
		<link rel="icon" href="img/favicon.ico">
		<link rel="shortcut icon" href="img/favicon.ico">
		<meta name="keywords" content="简洁，强大的二维码软件,QRTools,QRT,二维码">
		<meta name="description" content="简洁，强大的二维码软件">

		<script type="text/javascript" src="js/jquery-2.1.0.js"></script>
		<script type="text/javascript" src="js/qrcode.js"></script>
		<script type="text/javascript" src="js/qrcode.min.js"></script>

		<title>QRTools - 联系人二维码</title>

		<style type="text/css">
			body {
				margin: 0;
				padding: 0;
				background-color: #616161;
			}
			
			.view {
				margin: 20px;
				background-color: #ffffff;
				text-align: center;
			}
			
			.view2 {
				margin: 20px;
				background-color: #ffffff;
				padding: 20px;
			}
			
			#div2 {
				background-color: #616161;
				padding: 10px;
				color: #ffffff;
				font-size: 16px;
				margin: 10px;
				text-align: center;
			}
			
			#div3 {
				background-color: #616161;
				padding: 10px;
				color: #ffffff;
				font-size: 16px;
				margin: 10px;
				text-align: center;
			}
		</style>

	</head>

	<body>

		<div class="view2">

			<font id="textnum">请输入名字</font>

			<br />
			<br />
			<input type="text" id="text1" style="width: 100%;font-size: 25px;"></input>
			<br />		<br />
			<font id="textnum">请输入手机号</font>
			<br />
			<br />
			<input type="text" id="text2" style="width: 100%;font-size: 25px;"></input>

			<div id="div2" style="margin-top: 30px;">
				生成
			</div>
	
		</div>

		<div id="view3" style="background-color: #ffffff;padding: 10px;margin: 20px;">
			<div class="view" id="img_par">
				<div id="img1" style="width: 100%;" />
			</div>
		</div>

	</body>

	<script type="text/javascript">
		var btn1 = document.getElementById("div2");
		
		var text1 = document.getElementById("text1");
		var text2 = document.getElementById("text2");
		var imgview = document.getElementById("img1");
		var imgpar = document.getElementById("img_par");

		var qrcode = new QRCode("img1", {
			text: "QRTools",
			width: imgpar.offsetWidth,
			height: imgpar.offsetWidth,
			colorDark: "#000000",
			colorLight: "#ffffff",
			correctLevel: QRCode.CorrectLevel.H
		});

		function makeCode() {

			if(!text1.value || !text2.value) {
				alert("手机号不能为空!");
				elText.focus();
				return;
			}

			try {
				qrcode.makeCode('BEGIN:VCARD\nVERSION:3.0\nN:' + text1.value + '\nTEL:' + text2.value + '\nNOTE:QRTools Share\nEND:VCARD');
			} catch(e) {
				alert("生成失败！");
			}
		}


		btn1.onclick = function() {
			makeCode();
		}

		
	</script>

</html>